package com.wu.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class BeanObjectToMapUtils {
    /***
     * 对象转map
     * @param object
     * @return
     * @throws IllegalAccessException
     */
    public static Map<String, Object> beanToMap(Object object) {
        Map<String, Object> map = new HashMap<String, Object>();
        Field[] fields = object.getClass().getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            try {
				map.put(field.getName(), field.get(object));
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
        }
        return map;
    }

}
